package com.crm.biz.controller;


import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.HashMap;
import java.util.Map;

import org.dom4j.DocumentException;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.crm.util.XMLUtil;

@Controller
@RequestMapping("/bizInquiriesRules")
public class BizInquiriesRulesController {
	
	@RequestMapping("/index")
	public String index(ModelMap map) throws FileNotFoundException, DocumentException{
		
		Map<String, Object> resultMap = XMLUtil.parseInquiriesRule();
		
		map.put("map", resultMap);
		
		return "configuration/inquiriesRules";
	}
	
	@RequestMapping("/updateRecord")
	@ResponseBody
	public Map<String, Object> updateRecord(@RequestParam MultiValueMap<String, Object> params) throws DocumentException, URISyntaxException, IOException{
		
		
		System.out.println(params);
		
		Map<String, Object> map = new HashMap<>();
		
		XMLUtil.updateInquiriesRule(params);
		
		map.put("status", "success");
		map.put("msg", "提交成功！");
		
		return map;
	}
	

}
